<#import "/common/function.ftl" as fn>
<@fn.header _title="">
<#import "/spring.ftl" as spring />
<script type="text/javascript" src="${base}/resources/script/jquery.validate.js"></script>
<script type="text/javascript" src="${base}/resources/script/jquery.validate.methods.js"></script>
<script type="text/javascript" src="${base}/resources/script/date97/WdatePicker.js"></script>
<script type="text/javascript">
$(function() {
	var $validateErrorContainer = $("#validateErrorContainer");
	var $validateErrorLabelContainer = $("#validateErrorContainer ul");
	var $validateForm = $("#validateForm");
	
	// 表单验证
	$validateForm.validate({
		errorContainer: $validateErrorContainer,
		errorLabelContainer: $validateErrorLabelContainer,
		wrapper: "li",
		errorClass: "validateError",
		ignoreTitle: true,
		rules: {
			"name": "required",
			"description": "required",
			"regionId": "required"
		},
		messages: {
			"name": "请填写名称",
			"description": "请填写描述信息",
			"regionId": "请选择角色所属区域"
		},
		submitHandler: function(form) {
			$(form).find(":submit").attr("disabled", true);
			form.submit();
		}
	});	
});

</script>
</@fn.header>

<body style="width:100%" class="list">
<form id="validateForm" action="<#if isAddAction>save<#else>update</#if>" method="post">
	<h2><img src="${base}/resources/style/images/iconDivM.gif" width="16" height="16" />机构管理</h2>
	<div id="validateErrorContainer" class="validateErrorContainer marginTop15" style="display:none;">
		<div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
		<ul></ul>
	</div>
	<div class="title marginTop15">
		<div class="title-middle">
			<div class="title-left"></div>
			<div class="title-caption"><#if isAddAction>添加角色信息<#else>编辑机构信息</#if></div>
            <div class="title-right"></div>
		</div>
	</div>
	<table class="table3" id="userListTable">
		<tr>
			<th>
				名称: 
			</th>
			<td>
				<input type="text" name="name" class="formText" value="${(role.name)!}" />
				<label class="requireField"><font style="font-weight:bold">${(error)!}</font><#if role!=null><@spring.bind "roles.name" /><@spring.showErrors "br"/><#else>*</#if></label>
			</td>
		</tr>
		<tr>
			<th>
				角色所属机构: 
			</th>
			<td>
				<select id="regionId" name="regionId">
					<option value="">请选择角色所属机构</option>
					<#list regionList as region>
					<option value="${region.id}" <#if role!=null><#if regionId==region.id>selected</#if></#if>>${region.name}</option>
					</#list>
				</select>
				<label class="requireField">*</label>
			</td>
		</tr>
		<tr>
			<th>
				描述: 
			</th>
			<td>
				<input type="text" name="description" class="formText" size=50 value="${(role.description)!}" />
				<label class="requireField">*</label>
			</td>
		</tr>
	</table>
	<input type="submit" class="button" value="确 定" />
	<input type="button" class="button" value="返 回" onclick="javascript:history.go(-1);" />
</form>
</body>
</html>